package com.woniu.service.impl;

import com.woniu.entity.UserRegisterDTO;
import com.woniu.pojo.User;
import com.woniu.mapper.UserMapper;
import com.woniu.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.util.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 会员表 服务实现类
 * </p>
 *
 * @author xiaoruan
 * @since 2023-03-21
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    UserMapper userMapper;

    @Override
    public void register(UserRegisterDTO userRegisterDTO) {

        User user = new User();
        user.setMobile(userRegisterDTO.getPhone());
        String hash = Md5Utils.hash(userRegisterDTO.getPassword());

        user.setPassword(hash);
        userMapper.insert(user);


    }

    @Override
    public User getByPone(String phone) {
        return  userMapper.getByPone(phone);
    }
}

